#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QPushButton>
#include <QVariant>
#include "Views/chatlistwidget.h"
#include "Views/chatwidget.h"
#include "Views/contactlistwidget.h"
#include "Views/contactwidget.h"

enum Area {
    Top,
    Left,
    Right,
    Bottom,
    Center,
    TopLeft,
    TopRight,
    BottomLeft,
    BottomRight
};

enum ChatPage {
    AllChat,
    Contact,
    Collect,
};

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    Ui::MainWindow *ui;

    bool isMouseDown;
    QPoint m_pressPos;
    QRect m_pressRect;
    int m_posx, m_posy;
    Area m_area;

    QPushButton *m_btn;
    ChatPage m_page;

    // 聊天列表
    ChatListWidget m_allchatlist;
    ChatWidget m_allchatWidget;
    // 联系列表
    ContactListWidget m_contactlist;
    ContactWidget m_contactWidget;

    void init();
    void initData();

    Area getArea(int x, int y);
    void stickEvent();
    void mininEvent();
    void clozeEvent();
    void maxinEvent();
    void selectEvent();
    void onView(QVariant var, PageType type);

protected:
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    void mouseDoubleClickEvent(QMouseEvent *event);
    bool eventFilter(QObject *sender, QEvent *event);
};
#endif // MAINWINDOW_H
